<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page language="java" import="java.lang.*" %>
<%@ page import = "java.sql.SQLException" %>
<%@ page import = "com.seniorproject.aims.*" %>
<%@ page import = "java.util.List" %>
<%@page import="java.util.ArrayList"%>
<%@ page import = "java.util.Properties" %>
<%@ page import = "javax.servlet.ServletContext" %>
<%@ page import = "java.io.*" %>

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Enrollment Enrollment</title>
	
	<link rel="stylesheet" href="css/validation.css" />
	<link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css"/>
	<link rel="stylesheet" type="text/css" href="css/stylev2.css" />
	<link rel="stylesheet" type="text/css" href="css/student-system.css" /> 
	<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
	
	<style>
		.silvergrad td {
		    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFF', endColorstr='#CCC');
		    background: -webkit-gradient(linear, left top, left bottom, from(#FFF), to(#CCC));
		    background: -moz-linear-gradient(top, #FFF, #CCC);
		}
		.silvergrad:hover td {
		    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#999', endColorstr='#CCC');
		    background: -webkit-gradient(linear, left top, left bottom, from(#999), to(#CCC));
		    background: -moz-linear-gradient(top, #999, #CCC);
		    cursor: pointer;
		}
		
		.bluegrad td {
		    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#c9e3fd', endColorstr='#aad4ff');
		    background: -webkit-gradient(linear, left top, left bottom, from(#c9e3fd), to(#aad4ff));
		    background: -moz-linear-gradient(top, #c9e3fd, #aad4ff);
		}
		.bluegrad:hover td {
		    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#85b7eb', endColorstr='#cae1f8');
		    background: -webkit-gradient(linear, left top, left bottom, from(#85b7eb), to(#cae1f8));
		    background: -moz-linear-gradient(top, #85b7eb, #cae1f8);
		    cursor: pointer;
		}
		a {
	      text-decoration:none;
	   	}
	</style>
	
	<script>
	$(document).ready(function(){
		
		 $("#result_div").hide();
		
	 	 $("button").click(function(){
	 	
	 		 var name_in = document.getElementById("name_in").value;
	 		 var id_in = document.getElementById("id_in").value;
	 		 //var department_in = document.getElementById("department_in").value;
	 		 //var year_in = document.getElementById("year_in").value;
	 		 var select = document.getElementById("department_in");
			 var department_in = select.options[select.selectedIndex].value;		 
			 var select1 = document.getElementById("year_in");
			 var year_in = select1.options[select1.selectedIndex].value;
			
			 
			// alert("name:"+name_in+"|id:"+id_in+"|department:"+department_in+"|year:"+year_in);
			
			var name_temp = name_in.split(" ");
			//alert("name_temp.length  "+name_temp.length);//////////////////////////////////////
			if(name_temp.length >= 2) {
				alert("กรุณาใส่ชื่อให้ถูกต้อง");
  				return false;
			}
	 		 
	 		 var name_is_null = 1; //1 for null
	 		 var id_is_null  = 1;
	 		 var depart_is_null = 1;
	 		 var year_is_null  = 1;
	 		 
	 		 if(name_in=="") {
	 				 
	 		 }else{
	 			 if(name_in == parseInt(name_in,10)){
	 				alert("กรุณาใส่ชื่อให้ถูกต้อง");
	  				return false;
	 			 }
	 			 name_is_null = 0;
	 		 }
	 		
	 		 if(id_in==""){ 
	 		 }else{
	 			 if(!(id_in == parseInt(id_in,10))){
	  				alert("กรุณาใส่ ID ให้ถูกต้อง");
	   				return false;
	  			 }
	 			 id_is_null = 0;
	 		 }
	 		 
	 		 if(department_in=="select"){
	 			 
	 		 }else{
	 			
	 			 depart_is_null = 0;
	 		 }
	 		 
	 		 if(year_in=="select"){
	 			 
	 		 }else{
	 			 
	 	
	 			 year_is_null = 0;
	 		 }
	 		 
	 		
	 		
	 		 
	 	//	 alert(name_is_null +""+ id_is_null +""+ depart_is_null +""+ year_is_null);
	 		 if(name_is_null+id_is_null+depart_is_null+year_is_null==4)
	 		{
	 			 	alert("กรุณาใส่ keyword ค้นหา");		 
	 			 	return false;
	    	 }
	 		
	 		// alert("name:"+name_in+" id:"+id_in+" department:"+department_in+" year:"+year_in);
	 		
	 	var option = "";
	 		option = name_is_null.toString()+id_is_null.toString()+depart_is_null.toString()+year_is_null.toString();
	 		
	 		var sql_con = ""; 
	 		var start_date_con ="X"; 
	 		var start_date ;
			var date_now = new Date();
			var temp_year  = date_now.getFullYear();
			var temp_month = date_now.getMonth()+1;
			var name_con = "null";
			var year_high = false;
	 	//	alert("option is:"+option);
	 		
			switch(option){
			case "0000":

				switch (year_in){
					case "1":
				
						if(temp_month<6)
						{
							start_date = temp_year-1;
						}else{
							start_date = temp_year ;  
						}
					break;
					
					case "2":
				
						if(temp_month<6){
							
							start_date = temp_year-2;
						}else{
							start_date = temp_year-1;
							
						}			
					break;
					
					case "3":
					
						if(temp_month<6){
							
							start_date = temp_year-3;
						}else{
							start_date = temp_year-2;
							
						}	
						
					break;
					
					case "4":
					
						if(temp_month<6){
							
							start_date = temp_year-4;
						}else{
							start_date = temp_year-3;
							
						}	
					break ;
					
					case "5":
						
						if(temp_month<6){
							
							start_date = temp_year-4;
						}else{
							start_date = temp_year-3;
							
						}
						
						year_high = true;
						
					break;
				}
				
				sql_con =  " AND S.student_id='"+id_in
				+"' AND D.department_id='"+department_in+"' AND S.start_date ";
			start_date_con = start_date;
			name_con = name_in;
					
			
				break;
			case "0001":
				sql_con =  " AND S.student_id='"+id_in
				+"' AND D.department_id='"+department_in+"'";
				name_con = name_in;
					
				break;
			case "0010":
 				
 				switch (year_in){
					case "1":
				
						if(temp_month<6)
						{
							start_date = temp_year-1;
						}else{
							start_date = temp_year ;  
						}
					break;
					
					case "2":
				
						if(temp_month<6){
							
							start_date = temp_year-2;
						}else{
							start_date = temp_year-1;
							
						}			
					break;
					
					case "3":
					
						if(temp_month<6){
							
							start_date = temp_year-3;
						}else{
							start_date = temp_year-2;
							
						}	
						
					break;
					
					case "4":
					
						if(temp_month<6){
							
							start_date = temp_year-4;
						}else{
							start_date = temp_year-3;
							
						}	
					break ;
					
					case "5":
						
						if(temp_month<6){
							
							start_date = temp_year-4;
						}else{
							start_date = temp_year-3;
							
						}
						
						year_high = true;
						
						
					break;
				}
 				
 				sql_con =  " AND S.student_id='"+id_in
				+"' AND S.start_date ";
				start_date_con = start_date;
				name_con = name_in;
		
				
				break;
			case "0011":
				sql_con =  " AND S.student_id='"+id_in+"'";
				name_con = name_in;
				
				break;
			case "0100":
 				switch (year_in){
					case "1":
				
						if(temp_month<6)
						{
							start_date = temp_year-1;
						}else{
							start_date = temp_year ;  
						}
					break;
					
					case "2":
				
						if(temp_month<6){
							
							start_date = temp_year-2;
						}else{
							start_date = temp_year-1;
							
						}			
					break;
					
					case "3":
					
						if(temp_month<6){
							
							start_date = temp_year-3;
						}else{
							start_date = temp_year-2;
							
						}	
						
					break;
					
					case "4":
					
						if(temp_month<6){
							
							start_date = temp_year-4;
						}else{
							start_date = temp_year-3;
							
						}	
					break ;
					
					case "5":
						
						if(temp_month<6){
							
							start_date = temp_year-4;
						}else{
							start_date = temp_year-3;
							
						}
						
						year_high = true;
						
						
					break;
				}
 				sql_con =  " AND D.department_id='"+department_in+"' AND S.start_date ";
				start_date_con = start_date;
				name_con = name_in;
	

				break;
			case "0101":
				sql_con =  " AND D.department_id='"+department_in+"'";
				name_con = name_in;
		
				break;
			case "0110":
				switch (year_in){
					case "1":
				
						if(temp_month<6)
						{
							start_date = temp_year-1;
						}else{
							start_date = temp_year ;  
						}
					break;
					
					case "2":
				
						if(temp_month<6){
							
							start_date = temp_year-2;
						}else{
							start_date = temp_year-1;
							
						}			
					break;
					
					case "3":
					
						if(temp_month<6){
							
							start_date = temp_year-3;
						}else{
							start_date = temp_year-2;
							
						}	
						
					break;
					
					case "4":
					
						if(temp_month<6){
							
							start_date = temp_year-4;
						}else{
							start_date = temp_year-3;
							
						}	
					break ;
					
					case "5":
						
						if(temp_month<6){
							
							start_date = temp_year-4;
						}else{
							start_date = temp_year-3;
							
						}
						
						year_high = true;
						
						
					break;
				}
				sql_con =  " AND S.start_date ";
				start_date_con = start_date;
				name_con = name_in;
				
			
				break;
			case "0111":
				name_con = name_in;

 				break;
 			case "1000":
 				
	 				switch (year_in){
						case "1":
					
							if(temp_month<6)
							{
								start_date = temp_year-1;
							}else{
								start_date = temp_year ;  
							}
						break;
						
						case "2":
					
							if(temp_month<6){
								
								start_date = temp_year-2;
							}else{
								start_date = temp_year-1;
								
							}			
						break;
						
						case "3":
						
							if(temp_month<6){
								
								start_date = temp_year-3;
							}else{
								start_date = temp_year-2;
								
							}	
							
						break;
						
						case "4":
						
							if(temp_month<6){
								
								start_date = temp_year-4;
							}else{
								start_date = temp_year-3;
								
							}	
						break ;
						
						case "5":
							
							if(temp_month<6){
								
								start_date = temp_year-4;
							}else{
								start_date = temp_year-3;
								
							}
							
							year_high = true;
							
							
						break;
					}
	 				sql_con =  " AND S.student_id='"+id_in
					+"' AND D.department_id='"+department_in+"' AND S.start_date ";
					start_date_con = start_date;
					
 				break;
 			case "1001":
 				sql_con =  " AND S.student_id='"+id_in
					+"' AND D.department_id='"+department_in+"'";

 				break;
 			case "1010":
 				
	 				switch (year_in){
						case "1":
					
							if(temp_month<6)
							{
								start_date = temp_year-1;
							}else{
								start_date = temp_year ;  
							}
						break;
						
						case "2":
					
							if(temp_month<6){
								
								start_date = temp_year-2;
							}else{
								start_date = temp_year-1;
								
							}			
						break;
						
						case "3":
						
							if(temp_month<6){
								
								start_date = temp_year-3;
							}else{
								start_date = temp_year-2;
								
							}	
							
						break;
						
						case "4":
						
							if(temp_month<6){
								
								start_date = temp_year-4;
							}else{
								start_date = temp_year-3;
								
							}	
						break ;
						
						case "5":
							
							if(temp_month<6){
								
								start_date = temp_year-4;
							}else{
								start_date = temp_year-3;
								
							}
							
							year_high = true;
							
							
						break;
					}
	 				sql_con =  " AND S.student_id='"+id_in+"'"
					+" AND S.start_date ";
					start_date_con = start_date;
	

 				break;
 			case "1011":
 				sql_con = " AND S.student_id='"+id_in+"'";
	
 				break;
 			case "1100":
 				
	 				switch (year_in){
						case "1":
					
							if(temp_month<6)
							{
								start_date = temp_year-1;
							}else{
								start_date = temp_year ;  
							}
						break;
						
						case "2":
					
							if(temp_month<6){
								
								start_date = temp_year-2;
							}else{
								start_date = temp_year-1;
								
							}			
						break;
						
						case "3":
						
							if(temp_month<6){
								
								start_date = temp_year-3;
							}else{
								start_date = temp_year-2;
								
							}	
							
						break;
						
						case "4":
						
							if(temp_month<6){
								
								start_date = temp_year-4;
							}else{
								start_date = temp_year-3;
								
							}	
						break ;
						
						case "5":
							
							if(temp_month<6){
								
								start_date = temp_year-4;
							}else{
								start_date = temp_year-3;
								
							}
							
							year_high = true;
							
							
						break;
					}
				sql_con = " AND D.department_id='"+department_in+"' AND S.start_date ";
				start_date_con = start_date;
			
 				
 				break;
 			case "1101":
 				sql_con = " AND D.department_id='"+department_in+"'";
 				
 				break;
 			case "1110":

					switch (year_in){
						case "1":
					
							if(temp_month<6)
							{
								start_date = temp_year-1;
							}else{
								start_date = temp_year ;  
							}
						break;
						
						case "2":
					
							if(temp_month<6){
								
								start_date = temp_year-2;
							}else{
								start_date = temp_year-1;
								
							}			
						break;
						
						case "3":
						
							if(temp_month<6){
								
								start_date = temp_year-3;
							}else{
								start_date = temp_year-2;
								
							}	
							
						break;
						
						case "4":
						
							if(temp_month<6){
								
								start_date = temp_year-4;
							}else{
								start_date = temp_year-3;
								
							}	
						break ;
						
						case "5":
							
							if(temp_month<6){
								
								start_date = temp_year-4;
							}else{
								start_date = temp_year-3;
								
							}
							
							year_high = true;
							
							
						break;
					}
 				sql_con = " AND S.start_date ";
 				start_date_con = start_date;
 				
				
 				break;
 		
 		}
	 	

		  var xmlhttp;
			
			if(window.XMLHttpRequest) {
				// code for IE7+, Firefox, Chrome, Opera, Safari
				xmlhttp = new XMLHttpRequest();
			}
			else {
				// code for IE6, IE5
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			
			xmlhttp.onreadystatechange = function() {
				if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {	
					
					if($('#result_div').find('div').length > 0) {					
						$('#result_div').find('div').remove();
					}
					
					var jsonObj = JSON.parse(xmlhttp.responseText);
					
					//alert("I'm Back");
					if(jsonObj.length == 0) {
					//	massage();
						alert("ไม่พบข้อมูล");
					}
					else{
						//alert("That work !!!");
						
						
						head = '<div class="CSSTableGenerator">'
								+ '<table  width="950" border="1" align="center" id="table_student">'
								+ '<tr>'
				              	+ '<td width="80"><center><strong>รหัสนักศึกษา</strong></center></td>'
				              	+ '<td width="100"><center><strong>ชื่อ</strong></center></td>'
				              	+ '<td width="130"><center><strong>นามสกุล</strong></center></td>'
				              	+ '<td width="40"><center><strong>ชั้นปี</strong></center></td>'
				              	+ '<td width="100"><center><strong>สถานะ</strong></center></td>'
				              	+ '<td width="80"><center><strong>ภาควิชา</strong></center></td>'
				              	+ '</tr>';
								
						$('#result_div').append(head);
					
						for(i in jsonObj) {
							if(i%2 == 0) { 
								class_name = 'silvergrad';
							}
							else {
								class_name = 'bluegrad';
							}
							
							text = '<tr class="'+class_name+'" onclick="enroll_enrollment_add(\''+jsonObj[i].studentId+'\')">'
									+ '<td width="80"><center>'+jsonObj[i].studentId+'</center></td>'
									+ '<td width="80"><center>'+jsonObj[i].nameTH+'</center></td>'
									+ '<td width="80"><center>'+jsonObj[i].surnameTH+'</center></td>'
									+ '<td width="80"><center>'+jsonObj[i].year+'</center></td>'
									+ '<td width="80"><center>'+jsonObj[i].status+'</center></td>'
									+ '<td width="80"><center>'+jsonObj[i].department+'</center></td>'
									+ '</tr>';
									
							$('#table_student').append(text);
						}
						
						$('#result_div').append('</table></div>');
					}
					
					
					//System.out.println("temp_x:"+temp_x);	
				
				
				}// end if check state
			}// end function
			
			//xmlhttp.open("POST", "student_search_background.jsp?user_input_search=" + user_search_input+"&option="+option_value, true);
			//alert("sql_con:"+sql_con);	
			xmlhttp.open("POST", "student_search_background.jsp?sql_con="+sql_con+"&start_date_con="+start_date_con+"&name_con="+name_con+"&year_high="+year_high, true);
			
			xmlhttp.send();
		  
		  $("#result_div").show();
	  });
	 	 
	});
		
		function enroll_enrollment_add(id){
			// alert(id);
		   //window.location = "student_detail.jsp";
	   
		 	var form = document.createElement("form");
		    form.setAttribute("method", "post");
		    form.setAttribute("action", "enroll_enrollment_add.jsp");
		    var hiddenField = document.createElement("input");
		    hiddenField.setAttribute("type", "hidden");
	        hiddenField.setAttribute("name", "student_id");
	        hiddenField.setAttribute("id","student_id");
	        hiddenField.setAttribute("value", id);
	        form.appendChild(hiddenField);
	        
	        document.body.appendChild(form);
	        form.submit();
		}
	</script>
</head>
<body>

<%
	String strUser = String.valueOf(session.getAttribute("sUser"));
	HttpSession htp_session = request.getSession();
			
	if (htp_session == null || htp_session.getAttribute("sUser") == null) {
	    // Forward the control to login.jsp if authentication fails or session expires
	    request.getRequestDispatcher("/login.jsp").forward(request,
	        response);
	}
	
	if("admin".equals(htp_session.getAttribute("sUser"))){%>
	<script>alert("This user dont have PERMISSION to access this zone.");</script>
	<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=admin_home.jsp"> 	
	<%}
	
	//get permission 
	
		String name = String.valueOf(session.getAttribute("name"));
		String surname = String.valueOf(session.getAttribute("surname"));
		String role_name = String.valueOf(session.getAttribute("enrollment_role"));
		
		String department_id = String.valueOf(session.getAttribute("department_id"));

		
				
		System.out.println("name : " + name);///////////////////////////////
		System.out.println("department_id : " + department_id);/////////////////////////
		
		
		List<String> system_name = new ArrayList<String>();
		
		Permission permission = new Permission(strUser,name);
		permission.setDepartmentId(department_id);
		permission.setRegisCreate(Boolean.valueOf(String.valueOf(session.getAttribute("enrollment_create"))));
		permission.setRegisDelete(Boolean.valueOf(String.valueOf(session.getAttribute("enrollment_delete"))));
		permission.setRegisRead(Boolean.valueOf(String.valueOf(session.getAttribute("enrollment_read"))));
		permission.setRegisUpdate(Boolean.valueOf(String.valueOf(session.getAttribute("enrollment_update"))));
		
		//check permission
		if(!permission.getRegisCreate()){%>
			<script>alert("This user dont have PERMISSION to access this zone.");</script>
			<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=enroll_home.jsp"> 	
		<%}
		
	//set Database Connection
	String hostProps = "";
	String usernameProps  = "";
	String passwordProps  = "";
	String databaseProps = "";
	
	try {
		//get current path
		ServletContext servletContext = request.getSession().getServletContext();
		
		InputStream input = servletContext.getResourceAsStream("/properties/connectDB.properties");
		Properties props = new Properties();
		
		props.load(input);

		hostProps  = props.getProperty("host");
		usernameProps  = props.getProperty("username");
		passwordProps  = props.getProperty("password");
		databaseProps = props.getProperty("database");
	} catch (Exception e) { 
		out.println(e);  
	}
	
	// connect database
	Connection connect = null;		
	try {
		Class.forName("com.mysql.jdbc.Driver");
	
		connect =  DriverManager.getConnection("jdbc:mysql://" + hostProps  + "/" + databaseProps +
				"?user=" + usernameProps  + "&password=" + passwordProps + "&characterEncoding=tis620" );
	
		if(connect != null){
			System.out.println("Database Connect Sucesses.");
		} else {
			System.out.println("Database Connect Failed.");	
		}

	} catch (Exception e) {
		out.println(e.getMessage());
		e.printStackTrace();
	}
	
	
	/* find department in database */
	List<Department> department = new ArrayList<Department>();
	
	try {			   
		ResultSet rs_department;
		if(("0").equals(permission.getDepartment_id()))
		{
			  rs_department = connect.createStatement().executeQuery("SELECT department_id, department_name_th " 
						+ " FROM department " + " ORDER BY department_id");
		}
		else{
			
			
			  rs_department = connect.createStatement().executeQuery("SELECT department_id, department_name_th " 
						+ " FROM department " 
					    +" WHERE department_id="+permission.getDepartment_id()
					    );
		}
		
		while(rs_department.next()) {
			Department dep = new Department();
			
			dep.setDepartmentNameTH(rs_department.getString("department_name_th"));
			dep.setDepartmentId(Integer.parseInt(rs_department.getString("department_id")));
			
			department.add(dep);
		}
		
	} catch (SQLException e) {
		e.printStackTrace();
	}
	
	connect.close();
%>

<div id="page-wrap">
		<div id="inside">
			<table border="0">
				<tr style="font-size:24px">
					<td width="600" height="100" style= "background-color: #273b80;border: 0px ;padding: 0px; 0px;" >
						<div id="header_banner-2"></div>
					</td>
					
					<td width="680" height="100" style= "background-color: #273b80;border: 0px;padding: 0px; 0px;" >
						<p align="right"><label><font size="4" color="#ffffff">username : <%=strUser%>&nbsp;&nbsp;</font></label></p>
						<a href="logout.jsp"><p align="right"><label style="cursor: pointer;"><font size="3" color="#ffffff">log out &nbsp;</font></label></p></a>
					</td>
				</tr>
			</table>
			<table border="0">
				<tr style="font-size:10px">	
					<td width = "720" height="50" style= "background-color:#D0D0D0 ;">
						<center><a href="enroll_home.jsp"><h2><font color="#273b80"><label style="cursor: pointer;">หน้าแรก</label></font></h2></a></center>
					</td>
<%
			if(permission.getRegisRead()) {
%>
					<td width = "720" height="50" style= "background-color:#D0D0D0 ;">
						<center><a href="enroll_search.jsp"><h2><font color="#273b80"><label style="cursor: pointer;">ค้นหา</label></font></h2></a></center>
					</td>
					<td width = "720" height="50" style= "background-color:#D0D0D0 ;">
						<center><a href="enroll_summary.jsp"><h2><font color="#273b80"><label style="cursor: pointer;">สรุปผลการลงทะเบียน</label></font></h2></center>
					</td>
<%
			}
			if(permission.getRegisCreate()) {
%>	
					<td width = "720" height="50" style= "background-color:#FFFFFF ; border-bottom-color: #FFFFFF; border-left-color: #FFFFFF">
						<center><h2><font color="#273b80"><label>ลงทะเบียนรายวิชา</label></font></h2></center>
					</td>
					<td width = "720" height="50" style= "background-color:#D0D0D0 ;">
						<center><a href="enroll_timetable.jsp"><h2><font color="#273b80"><label style="cursor: pointer;">ตารางสอน</label></font></h2></a></center>
					</td>
<%
			}
			
%>
				</tr>
			</table>
				
				<div id="main-content-ac">					
						</br></br>
						
						<center>
					
						  <div style="font-size:15px;">
						  	<center>
								<font size="5">  ชื่อ <input type="text" name="name_in" id="name_in" style="font-size:15px;">  
								&nbsp;	รหัสนักศึกษา <input type="text" name="id_in" id="id_in" style="font-size:15px;">
							  			
								&nbsp;  ภาควิชา <select name="department_in" id="department_in" style="font-size:15px;">
								<!--   			<option value="select">Select</option>	 -->
<%
									for(Department dept : department) {
										if(dept.getDepartmentId() == 0) {
								%>
											<option value="select">Select</option>
								<% 	
										}
										else {
%>
											<option value="<%=dept.getDepartmentId()%>" id="<%=dept.getDepartmentId()%>"><%=dept.getDepartmentNameTH()%></option>	
<%										
										}
									}
%>	
	
										</select>
										
								 &nbsp;  ชั้นปี <select name="year_in" id="year_in" style="font-size:15px;">
								  			<option value="select">Select</option>
								  			<option value="1"> 1 </option>
								  			<option value="2"> 2 </option>
								  			<option value="3"> 3 </option>
								  			<option value="4"> 4 </option>
								  			<option value="5"> ปีสูง </option>
								  	   </select>
								 </font> 
								 <br><br>
								 <button style="height: 25px; width: 80px; font-size: medium; ">ค้นหา</button>
								 <br><br>							 
							</center>
				  	 	 </div>
				  	  
  						</center>
  						

						<center><div id="result_div"></div></center>					       
					       
						<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
				
				
			<div style="clear: both;"></div>				
			<div id="footer"></div>
			
		</div>		
			<div style="clear: both;"></div>		
   </div>				
</body>
</html>